#include "main.h"

char buff[16];
uint8_t buffLen = 0;
int16_t Console()
{
    uint8_t reByte;
    if (Getchar(&reByte))
    { //如果有用户数据输入
        if (reByte == '\r')
        { //分析数据
            SendData(reByte);
            buff[buffLen] = 0;
            buffLen = 0;
        }
        else if (reByte == '\b')
        {
            if (buffLen > 0)
            {
                SendData(reByte);
                buffLen--;
            }
        }
        else
        {
            if (buffLen < sizeof(buff))
            {
                SendData(reByte);
                buff[buffLen] = reByte;
                buffLen++;
            }
        }
    }
    return 0;
}
